/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jFPessoasEnderecos.java
 *
 * Created on 29/05/2012, 12:07:11
 */

package ecommercial;

import ecommercial.Classes.ClassConecta;
import ecommercial.Classes.ComboItem;
import ecommercial.Classes.Funcoes;
import ecommercial.Classes.Logradouros;
import ecommercial.Classes.PessoasEnderecos;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author vitiazze
 */
public class jFPessoasEnderecos extends javax.swing.JDialog {

    /** Creates new form jFPessoasEnderecos */
    public jFPessoasEnderecos() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        buscarjButton = new javax.swing.JButton();
        novojButton = new javax.swing.JButton();
        editarjButton = new javax.swing.JButton();
        salvarjButton = new javax.swing.JButton();
        salvarMaisjButton = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        alterarjButton = new javax.swing.JButton();
        excluirjButton = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        sairjButton = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        paisjTextField = new javax.swing.JTextField();
        paisjButton = new javax.swing.JButton();
        estadojTextField = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        estadojButton = new javax.swing.JButton();
        cidadejTextField = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        cidadejButton = new javax.swing.JButton();
        bairrojTextField = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        bairrojButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        logradourojComboBox = new javax.swing.JComboBox();
        localizarEnderecojButton = new javax.swing.JButton();
        atualizaEnderecojButton = new javax.swing.JButton();
        numerojTextField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        complementojTextField = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        tipoEnderecojComboBox = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        gradeEnderecosjTable = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(ecommercial.EcommercialApp.class).getContext().getResourceMap(jFPessoasEnderecos.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jToolBar1.setBackground(resourceMap.getColor("jToolBar1.background")); // NOI18N
        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setName("jToolBar1"); // NOI18N

        buscarjButton.setBackground(resourceMap.getColor("buscarjButton.background")); // NOI18N
        buscarjButton.setIcon(resourceMap.getIcon("buscarjButton.icon")); // NOI18N
        buscarjButton.setText(resourceMap.getString("buscarjButton.text")); // NOI18N
        buscarjButton.setFocusable(false);
        buscarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        buscarjButton.setName("buscarjButton"); // NOI18N
        buscarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        buscarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(buscarjButton);

        novojButton.setBackground(resourceMap.getColor("novojButton.background")); // NOI18N
        novojButton.setIcon(resourceMap.getIcon("novojButton.icon")); // NOI18N
        novojButton.setText(resourceMap.getString("novojButton.text")); // NOI18N
        novojButton.setFocusable(false);
        novojButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        novojButton.setName("novojButton"); // NOI18N
        novojButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        novojButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                novojButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(novojButton);

        editarjButton.setBackground(resourceMap.getColor("editarjButton.background")); // NOI18N
        editarjButton.setIcon(resourceMap.getIcon("editarjButton.icon")); // NOI18N
        editarjButton.setText(resourceMap.getString("editarjButton.text")); // NOI18N
        editarjButton.setFocusable(false);
        editarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editarjButton.setName("editarjButton"); // NOI18N
        editarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editarjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(editarjButton);

        salvarjButton.setBackground(resourceMap.getColor("salvarjButton.background")); // NOI18N
        salvarjButton.setIcon(resourceMap.getIcon("salvarjButton.icon")); // NOI18N
        salvarjButton.setText(resourceMap.getString("salvarjButton.text")); // NOI18N
        salvarjButton.setFocusable(false);
        salvarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        salvarjButton.setName("salvarjButton"); // NOI18N
        salvarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        salvarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                salvarjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(salvarjButton);

        salvarMaisjButton.setBackground(resourceMap.getColor("salvarMaisjButton.background")); // NOI18N
        salvarMaisjButton.setIcon(resourceMap.getIcon("salvarMaisjButton.icon")); // NOI18N
        salvarMaisjButton.setText(resourceMap.getString("salvarMaisjButton.text")); // NOI18N
        salvarMaisjButton.setFocusable(false);
        salvarMaisjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        salvarMaisjButton.setName("salvarMaisjButton"); // NOI18N
        salvarMaisjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        salvarMaisjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                salvarMaisjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(salvarMaisjButton);

        jSeparator1.setName("jSeparator1"); // NOI18N
        jToolBar1.add(jSeparator1);

        alterarjButton.setBackground(resourceMap.getColor("alterarjButton.background")); // NOI18N
        alterarjButton.setIcon(resourceMap.getIcon("alterarjButton.icon")); // NOI18N
        alterarjButton.setText(resourceMap.getString("alterarjButton.text")); // NOI18N
        alterarjButton.setFocusable(false);
        alterarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        alterarjButton.setName("alterarjButton"); // NOI18N
        alterarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        alterarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                alterarjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(alterarjButton);

        excluirjButton.setBackground(resourceMap.getColor("excluirjButton.background")); // NOI18N
        excluirjButton.setIcon(resourceMap.getIcon("excluirjButton.icon")); // NOI18N
        excluirjButton.setText(resourceMap.getString("excluirjButton.text")); // NOI18N
        excluirjButton.setFocusable(false);
        excluirjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        excluirjButton.setName("excluirjButton"); // NOI18N
        excluirjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        excluirjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                excluirjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(excluirjButton);

        jSeparator2.setName("jSeparator2"); // NOI18N
        jToolBar1.add(jSeparator2);

        sairjButton.setBackground(resourceMap.getColor("sairjButton.background")); // NOI18N
        sairjButton.setIcon(resourceMap.getIcon("sairjButton.icon")); // NOI18N
        sairjButton.setText(resourceMap.getString("sairjButton.text")); // NOI18N
        sairjButton.setFocusable(false);
        sairjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        sairjButton.setName("sairjButton"); // NOI18N
        sairjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        sairjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sairjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(sairjButton);

        jPanel1.setBackground(resourceMap.getColor("jPanel1.background")); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel2.setBackground(resourceMap.getColor("jPanel2.background")); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N

        jPanel5.setBackground(resourceMap.getColor("jPanel5.background")); // NOI18N
        jPanel5.setName("jPanel5"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        paisjTextField.setEditable(false);
        paisjTextField.setText(resourceMap.getString("paisjTextField.text")); // NOI18N
        paisjTextField.setName("paisjTextField"); // NOI18N

        paisjButton.setIcon(resourceMap.getIcon("paisjButton.icon")); // NOI18N
        paisjButton.setText(resourceMap.getString("paisjButton.text")); // NOI18N
        paisjButton.setContentAreaFilled(false);
        paisjButton.setName("paisjButton"); // NOI18N
        paisjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                paisjButtonActionPerformed(evt);
            }
        });

        estadojTextField.setEditable(false);
        estadojTextField.setText(resourceMap.getString("estadojTextField.text")); // NOI18N
        estadojTextField.setName("estadojTextField"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        estadojButton.setIcon(resourceMap.getIcon("estadojButton.icon")); // NOI18N
        estadojButton.setText(resourceMap.getString("estadojButton.text")); // NOI18N
        estadojButton.setContentAreaFilled(false);
        estadojButton.setName("estadojButton"); // NOI18N
        estadojButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                estadojButtonActionPerformed(evt);
            }
        });

        cidadejTextField.setEditable(false);
        cidadejTextField.setText(resourceMap.getString("cidadejTextField.text")); // NOI18N
        cidadejTextField.setName("cidadejTextField"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        cidadejButton.setIcon(resourceMap.getIcon("cidadejButton.icon")); // NOI18N
        cidadejButton.setText(resourceMap.getString("cidadejButton.text")); // NOI18N
        cidadejButton.setContentAreaFilled(false);
        cidadejButton.setName("cidadejButton"); // NOI18N
        cidadejButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cidadejButtonActionPerformed(evt);
            }
        });

        bairrojTextField.setEditable(false);
        bairrojTextField.setText(resourceMap.getString("bairrojTextField.text")); // NOI18N
        bairrojTextField.setName("bairrojTextField"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        bairrojButton.setIcon(resourceMap.getIcon("bairrojButton.icon")); // NOI18N
        bairrojButton.setText(resourceMap.getString("bairrojButton.text")); // NOI18N
        bairrojButton.setContentAreaFilled(false);
        bairrojButton.setName("bairrojButton"); // NOI18N
        bairrojButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bairrojButtonActionPerformed(evt);
            }
        });

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        logradourojComboBox.setName("logradourojComboBox"); // NOI18N
        logradourojComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logradourojComboBoxActionPerformed(evt);
            }
        });

        localizarEnderecojButton.setIcon(resourceMap.getIcon("localizarEnderecojButton.icon")); // NOI18N
        localizarEnderecojButton.setText(resourceMap.getString("localizarEnderecojButton.text")); // NOI18N
        localizarEnderecojButton.setToolTipText(resourceMap.getString("localizarEnderecojButton.toolTipText")); // NOI18N
        localizarEnderecojButton.setContentAreaFilled(false);
        localizarEnderecojButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        localizarEnderecojButton.setName("localizarEnderecojButton"); // NOI18N
        localizarEnderecojButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                localizarEnderecojButtonActionPerformed(evt);
            }
        });

        atualizaEnderecojButton.setIcon(resourceMap.getIcon("atualizaEnderecojButton.icon")); // NOI18N
        atualizaEnderecojButton.setText(resourceMap.getString("atualizaEnderecojButton.text")); // NOI18N
        atualizaEnderecojButton.setContentAreaFilled(false);
        atualizaEnderecojButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        atualizaEnderecojButton.setName("atualizaEnderecojButton"); // NOI18N
        atualizaEnderecojButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                atualizaEnderecojButtonActionPerformed(evt);
            }
        });

        numerojTextField.setText(resourceMap.getString("numerojTextField.text")); // NOI18N
        numerojTextField.setName("numerojTextField"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        complementojTextField.setText(resourceMap.getString("complementojTextField.text")); // NOI18N
        complementojTextField.setName("complementojTextField"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        tipoEnderecojComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Residencial", "Comercial", "Entrega" }));
        tipoEnderecojComboBox.setName("tipoEnderecojComboBox"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(paisjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(paisjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel8))
                        .addGap(6, 6, 6)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(estadojTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(estadojButton, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel7)))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(logradourojComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(localizarEnderecojButton, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(atualizaEnderecojButton, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(numerojTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(6, 6, 6)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel6)
                    .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(complementojTextField, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(cidadejTextField, javax.swing.GroupLayout.Alignment.LEADING)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cidadejButton, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel4)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(tipoEnderecojComboBox, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(bairrojTextField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bairrojButton, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {bairrojTextField, cidadejTextField, estadojTextField});

        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(paisjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(paisjButton)))
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(estadojTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(estadojButton)))
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel5))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(bairrojTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cidadejButton)
                                    .addComponent(cidadejTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(bairrojButton))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(logradourojComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(atualizaEnderecojButton)
                                .addComponent(localizarEnderecojButton))
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel4))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(numerojTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(complementojTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(tipoEnderecojComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(62, 62, 62)
                        .addComponent(jLabel3)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel2.TabConstraints.tabTitle"), jPanel2); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 859, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(37, Short.MAX_VALUE))
        );

        jPanel3.setBackground(resourceMap.getColor("jPanel3.background")); // NOI18N
        jPanel3.setName("jPanel3"); // NOI18N

        jPanel4.setBackground(resourceMap.getColor("jPanel4.background")); // NOI18N
        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel4.setName("jPanel4"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        gradeEnderecosjTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "#Id", "Endereço", "Tipo Endereço"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        gradeEnderecosjTable.setName("gradeEnderecosjTable"); // NOI18N
        gradeEnderecosjTable.getTableHeader().setReorderingAllowed(false);
        gradeEnderecosjTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                gradeEnderecosjTableMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(gradeEnderecosjTable);
        gradeEnderecosjTable.getColumnModel().getColumn(0).setResizable(false);
        gradeEnderecosjTable.getColumnModel().getColumn(0).setPreferredWidth(10);
        gradeEnderecosjTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("gradeEnderecosjTable.columnModel.title0")); // NOI18N
        gradeEnderecosjTable.getColumnModel().getColumn(1).setResizable(false);
        gradeEnderecosjTable.getColumnModel().getColumn(1).setPreferredWidth(480);
        gradeEnderecosjTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("gradeEnderecosjTable.columnModel.title1")); // NOI18N
        gradeEnderecosjTable.getColumnModel().getColumn(2).setResizable(false);
        gradeEnderecosjTable.getColumnModel().getColumn(2).setPreferredWidth(60);
        gradeEnderecosjTable.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("gradeEnderecosjTable.columnModel.title2")); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 819, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(26, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 879, Short.MAX_VALUE)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    ClassConecta conexao = new ClassConecta();

    int cod_logradouro;

    int cod_pessoa;

    ComboItem comboLogradouro;

    int cod_pais;
    int cod_estado;
    int cod_cidade;
    int cod_bairro;


    String pais;
    String estado;
    String cidade;
    String bairros;
    String logradouros;


//******************************************************************************************************
    public void getGradeEnderecos() throws ParseException{
       //Consultar Endereços
        PessoasEnderecos oPessoaEndereco= new PessoasEnderecos();


//        if ( logradourojTextField.getText().length() > 0 ){
//            oLogradouro.setLogradouro(logradourojTextField.getText()+"%");
//        }

        ResultSet resultSet = null;

        String[] colunasTabela = new String[]{"#Id", "Endereço", "Tipo Endereço"};
        DefaultTableModel modeloTabela = new DefaultTableModel(null, colunasTabela) {

            @Override
            public boolean isCellEditable(int row, int col) {
                return false;
            }
        };
        gradeEnderecosjTable.setModel(modeloTabela);
        gradeEnderecosjTable.getColumnModel().getColumn(0).setPreferredWidth(10);
        gradeEnderecosjTable.getColumnModel().getColumn(1).setPreferredWidth(480);
        gradeEnderecosjTable.getColumnModel().getColumn(2).setPreferredWidth(60);
try {


    oPessoaEndereco.setCod_pessoa(cod_pessoa);
            resultSet = oPessoaEndereco.getConsultar();

            if (resultSet.getRow() == 1){
             resultSet.first();
            }


        } catch (SQLException ex) {
            Logger.getLogger(Logradouros.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {

            while (resultSet.next()) {

                modeloTabela.addRow(new String[]{
                    Funcoes.getCodigoFormat(resultSet.getInt("COD_LOGRADOURO")),
                    resultSet.getString("TIPO")+ " " +resultSet.getString("LOGRADOURO")+ " " + resultSet.getString("NUMERO")+ " "
                            + resultSet.getString("COMPLEMENTO")+ " " +resultSet.getString("BAIRRO")
                            + " " + resultSet.getString("CIDADE")+ " "+ resultSet.getString("ESTADO")+ "  " + resultSet.getString("SIGLA")
                            + "  " + resultSet.getString("PAIS"),
                    resultSet.getString("TIPO_ENDERECO"),

                });

            }

        } catch (SQLException ex) {
            Logger.getLogger(Logradouros.class.getName()).log(Level.SEVERE, null, ex);
        }

           }


    public void getFieldPessoaEndereco(int cod_pessoa, int cod_logradouro) throws ParseException{

        PessoasEnderecos oPessoaEndereco = new PessoasEnderecos();
        ResultSet rs = null;
        oPessoaEndereco.setCod_endereco(cod_logradouro);
        oPessoaEndereco.setCod_pessoa(cod_pessoa);


        try {
            rs = oPessoaEndereco.getConsultar();
            rs.next();

            ComboItem oItem = new ComboItem(rs.getInt("COD_LOGRADOURO"), rs.getString("LOGRADOURO"));

            //Pegar campos
            logradourojComboBox.setSelectedItem(oItem);
            numerojTextField.setText(rs.getString("NUMERO"));
            complementojTextField.setText(rs.getString("COMPLEMENTO"));
            tipoEnderecojComboBox.setSelectedItem(rs.getString("TIPO_ENDERECO"));

        } catch (SQLException ex) {
            Logger.getLogger(Logradouros.class.getName()).log(Level.SEVERE, null, ex);
        }
    }


    private void sairjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sairjButtonActionPerformed
        // TODO add your handling code here:
        if (!novojButton.isEnabled()){
                Object[] options = {"Sim", "Não"};
                int sd = JOptionPane.showOptionDialog(null, "Deseja realmente SAIR?", "Confirmação do Sistema!", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
                if (sd != 0) {
                    return;
                }

                this.dispose();

            }else{

                this.dispose();

            }
    }//GEN-LAST:event_sairjButtonActionPerformed

    private void localizarEnderecojButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_localizarEnderecojButtonActionPerformed
        // TODO add your handling code here:
        jFBuscaEndereco oBuscaEndereco = new jFBuscaEndereco();

        oBuscaEndereco.conexao       = conexao;
        oBuscaEndereco.Titulo_Form = "Logradouros";
        oBuscaEndereco.setTitle("Logradouros");
        oBuscaEndereco.operacao = 4;
        oBuscaEndereco.cod_logradouro_bairro = cod_bairro;

        oBuscaEndereco.setDefaultCloseOperation(jFBuscaEndereco.DO_NOTHING_ON_CLOSE);
        oBuscaEndereco.pack();
        oBuscaEndereco.setModal(true);
        oBuscaEndereco.setLocationRelativeTo(null);
        oBuscaEndereco.setVisible(true);
        atualizaEnderecojButtonActionPerformed(null);
        
        logradouros = oBuscaEndereco.logradouro_busca_end;
        cod_logradouro = oBuscaEndereco.cod_operacao;

        atualizaEnderecojButtonActionPerformed(null);

        logradourojComboBox.setSelectedItem(logradouros);


    }//GEN-LAST:event_localizarEnderecojButtonActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        // TODO add your handling code here:

        salvarjButton.setEnabled(false);
        salvarMaisjButton.setEnabled(false);
        alterarjButton.setEnabled(false);
        excluirjButton.setEnabled(false);
        editarjButton.setEnabled(false);
        novojButton.setEnabled(true);

        estadojButton.setEnabled(false);
        cidadejButton.setEnabled(false);
        bairrojButton.setEnabled(false);

        estadojTextField.setText("");
        cidadejTextField.setText("");
        bairrojTextField.setText("");

        ClassConecta.conecta();

        buscarjButtonActionPerformed(null);

        cod_logradouro = 0;
    }//GEN-LAST:event_formWindowOpened

    private void buscarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarjButtonActionPerformed
        // TODO add your handling code here:

        atualizaEnderecojButtonActionPerformed(null);
        try {
            getGradeEnderecos();
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoasEnderecos.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_buscarjButtonActionPerformed

    private void atualizaEnderecojButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_atualizaEnderecojButtonActionPerformed
        // TODO add your handling code here:
        try {
            Logradouros oLogradouro = new Logradouros();
            ResultSet rs = null;

            oLogradouro.setCod_logradouro(cod_logradouro);
            rs = oLogradouro.getConsultar();
            logradourojComboBox.removeAllItems();
            while (rs.next()) {
                logradourojComboBox.addItem(new ComboItem(rs.getInt("COD_LOGRADOURO"), rs.getString("LOGRADOURO")));
            }
            logradourojComboBox.updateUI();
        } catch (SQLException ex) {
            Logger.getLogger(jFLogradouros.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_atualizaEnderecojButtonActionPerformed

    private void logradourojComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logradourojComboBoxActionPerformed
        // TODO add your handling code here:
        try {
            Logradouros oLogradouro = new Logradouros();
            ResultSet rs = null;

            comboLogradouro = (ComboItem) logradourojComboBox.getSelectedItem();
            oLogradouro.setCod_logradouro(cod_logradouro);
            rs = oLogradouro.getConsultar();

            while (rs.next()){
                bairrojTextField.setText(rs.getString("BAIRRO"));
                cidadejTextField.setText(rs.getString("CIDADE"));
                estadojTextField.setText(rs.getString("ESTADO"));
                paisjTextField.setText(rs.getString("PAIS"));
            }
        } catch (SQLException ex) {
            Logger.getLogger(jFCidades.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_logradourojComboBoxActionPerformed

    private void novojButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_novojButtonActionPerformed
        // TODO add your handling code here:
        novojButton.setEnabled(false);
        alterarjButton.setEnabled(false);
        editarjButton.setEnabled(false);
        excluirjButton.setEnabled(false);
        buscarjButton.setEnabled(true);
        salvarjButton.setEnabled(true);
        salvarMaisjButton.setEnabled(true);
        try {
            ClassConecta.con.setAutoCommit(false);
        } catch (SQLException ex) {
            Logger.getLogger(jFBairros.class.getName()).log(Level.SEVERE, null, ex);
        }
        paisjButtonActionPerformed(null);
    }//GEN-LAST:event_novojButtonActionPerformed

    private void salvarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salvarjButtonActionPerformed
        // TODO add your handling code here:
            salvarjButton.setEnabled(false);
            salvarMaisjButton.setEnabled(false);
            alterarjButton.setEnabled(false);
            excluirjButton.setEnabled(false);
            novojButton.setEnabled(true);
            editarjButton.setEnabled(true);

            PessoasEnderecos oPessoaEndereco = new PessoasEnderecos();

            comboLogradouro = (ComboItem) logradourojComboBox.getSelectedItem();

            oPessoaEndereco.setCod_pessoa(cod_pessoa);
            oPessoaEndereco.setCod_endereco(cod_logradouro);

            oPessoaEndereco.setNumero(numerojTextField.getText().trim().toUpperCase());
            oPessoaEndereco.setComplemento(complementojTextField.getText().trim().toUpperCase());
            oPessoaEndereco.setTipo_endereco(tipoEnderecojComboBox.getSelectedItem().toString());

            oPessoaEndereco.setCadastrar();
        try {
            ClassConecta.con.commit();
            ClassConecta.con.setAutoCommit(true);
        } catch (SQLException ex) {
            Logger.getLogger(jFPessoasEnderecos.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            getGradeEnderecos();
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoasEnderecos.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_salvarjButtonActionPerformed

    private void editarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editarjButtonActionPerformed
        // TODO add your handling code here:
            novojButton.setEnabled(false);
            salvarjButton.setEnabled(false);
            salvarMaisjButton.setEnabled(false);
            editarjButton.setEnabled(false);
            alterarjButton.setEnabled(true);
            excluirjButton.setEnabled(true);
        try {
            ClassConecta.con.setAutoCommit(false);
        } catch (SQLException ex) {
            Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_editarjButtonActionPerformed

    private void salvarMaisjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salvarMaisjButtonActionPerformed
        // TODO add your handling code here:
        salvarjButtonActionPerformed(null);
        novojButtonActionPerformed(null);
    }//GEN-LAST:event_salvarMaisjButtonActionPerformed

    private void alterarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_alterarjButtonActionPerformed
        // TODO add your handling code here:
        alterarjButton.setEnabled(false);
        editarjButton.setEnabled(true);
        excluirjButton.setEnabled(false);
        novojButton.setEnabled(true);

        PessoasEnderecos oPessoaEndereco = new PessoasEnderecos();

        comboLogradouro = (ComboItem) logradourojComboBox.getSelectedItem();

        oPessoaEndereco.setCod_pessoa(cod_pessoa);
        oPessoaEndereco.setCod_endereco(cod_logradouro);

        oPessoaEndereco.setNumero(numerojTextField.getText().trim().toUpperCase());
        oPessoaEndereco.setComplemento(complementojTextField.getText().trim().toUpperCase());
        oPessoaEndereco.setTipo_endereco(tipoEnderecojComboBox.getSelectedItem().toString());
        oPessoaEndereco.setCod_endereco(comboLogradouro.getId());

        oPessoaEndereco.setAlterar(conexao);
        try {
            ClassConecta.con.commit();
            ClassConecta.con.setAutoCommit(true);
        } catch (SQLException ex) {
            Logger.getLogger(jFPessoasEnderecos.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            getGradeEnderecos();
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoasEnderecos.class.getName()).log(Level.SEVERE, null, ex);
        }


    }//GEN-LAST:event_alterarjButtonActionPerformed

    private void excluirjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_excluirjButtonActionPerformed
        // TODO add your handling code here:
        Object[] options = {"Sim", "Não"};
        int sd =
                JOptionPane.showOptionDialog(null, "Deseja realmente EXCLUIR esse registro?", "Confirmação do Sistema!", JOptionPane.DEFAULT_OPTION,
                JOptionPane.WARNING_MESSAGE, null, options, options[0]);

        if (sd != 0) {
            return;
        }
        alterarjButton.setEnabled(false);
        editarjButton.setEnabled(true);
        excluirjButton.setEnabled(false);
        novojButton.setEnabled(true);

        PessoasEnderecos oPessoaEndereco = new PessoasEnderecos();
        oPessoaEndereco.setCod_endereco(cod_logradouro);
        oPessoaEndereco.setCod_pessoa(cod_pessoa);

        oPessoaEndereco.setExcluir();
        try {
            ClassConecta.con.commit();
            ClassConecta.con.setAutoCommit(true);
        } catch (SQLException ex) {
            Logger.getLogger(jFPaises.class.getName()).log(Level.SEVERE, null, ex);
        }

            numerojTextField.setText("");
            numerojTextField.setText("");
            tipoEnderecojComboBox.setSelectedItem("Residencial");
        try {
            getGradeEnderecos();
        } catch (ParseException ex) {
            Logger.getLogger(jFPaises.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_excluirjButtonActionPerformed

    private void gradeEnderecosjTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_gradeEnderecosjTableMouseClicked
        // TODO add your handling code here:
        editarjButton.setEnabled(true);
            cod_logradouro = Integer.parseInt(gradeEnderecosjTable.getValueAt(gradeEnderecosjTable.getSelectedRow(), 0).toString());
            if (cod_logradouro == 0) {
                return;
            }
        try {
            getFieldPessoaEndereco(cod_pessoa, cod_logradouro);
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoasEnderecos.class.getName()).log(Level.SEVERE, null, ex);
        }
            atualizaEnderecojButtonActionPerformed(null);
    }//GEN-LAST:event_gradeEnderecosjTableMouseClicked

    private void paisjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_paisjButtonActionPerformed
        // TODO add your handling code here:
        jFBuscaEndereco oBuscaEndereco = new jFBuscaEndereco();

        oBuscaEndereco.conexao       = conexao;
        oBuscaEndereco.Titulo_Form = "Países";
        oBuscaEndereco.setTitle("Países");
        oBuscaEndereco.operacao = 0;

        estadojButton.setEnabled(false);
        cidadejButton.setEnabled(false);
        bairrojButton.setEnabled(false);

        estadojTextField.setText("");
        cidadejTextField.setText("");
        bairrojTextField.setText("");
        
        oBuscaEndereco.setDefaultCloseOperation(jFBuscaEndereco.DO_NOTHING_ON_CLOSE);
        oBuscaEndereco.pack();
        oBuscaEndereco.setModal(true);
        oBuscaEndereco.setLocationRelativeTo(null);
        oBuscaEndereco.setVisible(true);
        atualizaEnderecojButtonActionPerformed(null);

        estadojButton.setEnabled(true);

        pais = oBuscaEndereco.pais_Busca_end;
        cod_pais = oBuscaEndereco.cod_operacao;

        paisjTextField.setText(pais);
    }//GEN-LAST:event_paisjButtonActionPerformed

    private void estadojButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_estadojButtonActionPerformed
        // TODO add your handling code here:
        jFBuscaEndereco oBuscaEndereco = new jFBuscaEndereco();

        oBuscaEndereco.conexao       = conexao;
        oBuscaEndereco.Titulo_Form = "Estados";
        oBuscaEndereco.setTitle("Estados");
        oBuscaEndereco.operacao = 1;
        oBuscaEndereco.cod_pais_estado = cod_pais;

        cidadejButton.setEnabled(false);
        bairrojButton.setEnabled(false);

        cidadejTextField.setText("");
        bairrojTextField.setText("");


        oBuscaEndereco.setDefaultCloseOperation(jFBuscaEndereco.DO_NOTHING_ON_CLOSE);
        oBuscaEndereco.pack();
        oBuscaEndereco.setModal(true);
        oBuscaEndereco.setLocationRelativeTo(null);
        oBuscaEndereco.setVisible(true);
        atualizaEnderecojButtonActionPerformed(null);

        cidadejButton.setEnabled(true);

        estado = oBuscaEndereco.estado_busca_end;
        cod_estado = oBuscaEndereco.cod_operacao_estado;

        estadojTextField.setText(estado);
    }//GEN-LAST:event_estadojButtonActionPerformed

    private void cidadejButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cidadejButtonActionPerformed
        // TODO add your handling code here:
        jFBuscaEndereco oBuscaEndereco = new jFBuscaEndereco();

        oBuscaEndereco.conexao       = conexao;
        oBuscaEndereco.Titulo_Form = "Cidades";
        oBuscaEndereco.setTitle("Cidades");
        oBuscaEndereco.operacao = 2;
        oBuscaEndereco.cod_cidade_estado = cod_estado;

        bairrojButton.setEnabled(false);

        bairrojTextField.setText("");


        oBuscaEndereco.setDefaultCloseOperation(jFBuscaEndereco.DO_NOTHING_ON_CLOSE);
        oBuscaEndereco.pack();
        oBuscaEndereco.setModal(true);
        oBuscaEndereco.setLocationRelativeTo(null);
        oBuscaEndereco.setVisible(true);
        atualizaEnderecojButtonActionPerformed(null);

        bairrojButton.setEnabled(true);

        cidade = oBuscaEndereco.cidade_busca_end;
        cod_cidade = oBuscaEndereco.cod_operacao;

        cidadejTextField.setText(oBuscaEndereco.cidade_busca_end);
    }//GEN-LAST:event_cidadejButtonActionPerformed

    private void bairrojButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bairrojButtonActionPerformed
        // TODO add your handling code here:
        jFBuscaEndereco oBuscaEndereco = new jFBuscaEndereco();

        oBuscaEndereco.conexao       = conexao;
        oBuscaEndereco.Titulo_Form = "Bairros";
        oBuscaEndereco.setTitle("Bairros");
        oBuscaEndereco.operacao = 3;
        oBuscaEndereco.cod_cidade_bairro = cod_cidade;


        oBuscaEndereco.setDefaultCloseOperation(jFBuscaEndereco.DO_NOTHING_ON_CLOSE);
        oBuscaEndereco.pack();
        oBuscaEndereco.setModal(true);
        oBuscaEndereco.setLocationRelativeTo(null);
        oBuscaEndereco.setVisible(true);
        atualizaEnderecojButtonActionPerformed(null);

        bairros = oBuscaEndereco.bairro_busca_end;
        cod_bairro = oBuscaEndereco.cod_operacao;

        bairrojTextField.setText(bairros);
    }//GEN-LAST:event_bairrojButtonActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new jFPessoasEnderecos().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton alterarjButton;
    private javax.swing.JButton atualizaEnderecojButton;
    private javax.swing.JButton bairrojButton;
    private javax.swing.JTextField bairrojTextField;
    private javax.swing.JButton buscarjButton;
    private javax.swing.JButton cidadejButton;
    private javax.swing.JTextField cidadejTextField;
    private javax.swing.JTextField complementojTextField;
    private javax.swing.JButton editarjButton;
    private javax.swing.JButton estadojButton;
    private javax.swing.JTextField estadojTextField;
    private javax.swing.JButton excluirjButton;
    private javax.swing.JTable gradeEnderecosjTable;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JButton localizarEnderecojButton;
    private javax.swing.JComboBox logradourojComboBox;
    private javax.swing.JButton novojButton;
    private javax.swing.JTextField numerojTextField;
    private javax.swing.JButton paisjButton;
    private javax.swing.JTextField paisjTextField;
    private javax.swing.JButton sairjButton;
    private javax.swing.JButton salvarMaisjButton;
    private javax.swing.JButton salvarjButton;
    private javax.swing.JComboBox tipoEnderecojComboBox;
    // End of variables declaration//GEN-END:variables

}
